fix: don't append trailing space when selecting autocomplete group names (#3710)#3976
Open
shengxinzhe wants to merge 1 commit intoconversejs:masterfrom
Open
fix: don't append trailing space when selecting autocomplete group names (#3710)#3976shengxinzhe wants to merge 1 commit intoconversejs:masterfrom
shengxinzhe wants to merge 1 commit intoconversejs:masterfrom
Conversation
…mes (conversejs#3710) When selecting a group name from the autocomplete dropdown with the mouse, a trailing space was appended to the value. This happened because replaceCurrentWord() always added a space suffix, which is correct for chat mentions but not for comma-separated fields like contact groups. Add a configurable `suffix` option to the autocomplete component that defaults to a space (preserving existing behavior for mentions) but can be set to an empty string for fields where no trailing space is desired. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3710
When selecting a group name from the autocomplete dropdown with the mouse, a trailing space character was appended to the value. This made the saved group name different from the expected one (e.g.,
"Friends "instead of"Friends").Root cause:
replaceCurrentWord()insrc/utils/form.jsalways appended a space after the autocompleted value. This is correct behavior for chat mentions (e.g.,@username) but wrong for form fields like comma-separated group names.Fix: Add a configurable
suffixoption to theAutoCompleteclass and theconverse-autocompletecomponent:' '(preserves existing behavior for mentions)suffix=""on the groups autocomplete in the "Add Contact" and "Accept Contact Request" modalsChanges:
src/utils/form.js- Add optionalsuffixparameter toreplaceCurrentWord()src/shared/autocomplete/autocomplete.js- Addsuffixconfig property, pass toreplaceCurrentWord()src/shared/autocomplete/component.js- Exposesuffixas a Lit propertysrc/plugins/rosterview/modals/templates/add-contact.js- Setsuffix=""on groups autocompletesrc/plugins/rosterview/modals/templates/accept-contact-request.js- Setsuffix=""on groups autocomplete